<template>
<div>
     <el-button type="primary" style="width:200px" @click="ks()">开始考试</el-button>
    
    <fm-generate-form :data="jsonData" ref="generateForm"></fm-generate-form>
    <div>
        
         <el-button type="primary" style="width:200px" @click="add()">交卷</el-button>
    </div>
 
</div>
</template>

<script>
export default {
  data () {
    return {
      tableDate:[],
      jsonData:'',
      content:null,
      id:'',
      quest:{

      },
      form:{
         
          userid:'',
          qId:'',
          tid:'',
          tkid:'',
          
      }
    }
  },
  mounted(){
      this.select();
  },
  //用户id     localStorage.setItem("userid",s.data.id)
  //题库一级 localStorage.setItem("qId",x.data.qId)
    //题库二级 localStorage.setItem("tid",x.data.tid)
  //试题id   localStorage.getItem('id');
  
  methods: {
     select(){
           this.id=localStorage.getItem('id');
        
           this.axios.get("https://localhost:44347/FindTK?id="+this.id).then(x=>{
           this.jsonData=JSON.parse(x.data.text)
           this.content=x.data.names
        
           localStorage.setItem("qId",x.data.qId)
           localStorage.setItem("tid",x.data.tid)
        })
     },
     ks(){

         this.form.userid= localStorage.getItem("userid")
                alert(this.form.userid)
                this.form.qId=localStorage.getItem("qId")
                alert(this.form.qId)
                this.form.tid=localStorage.getItem("tid")
                alert(this.form.tid)
                this.form.tkid=localStorage.getItem('id')
                alert(this.form.tkid)
         this.axios
         .post("https://localhost:44347/AddExam",this.form)
         .then(s=>{
               
             if(s.data==1)
             {
                 alert("已开始考试")
             }
             else
             {
                 alert("RBQ了")
             }
         })
     },
     add(){

     }
  }
}
</script>